StupidBeauty
Read times:451Posted at:Mon Jun 18 01:53:39 2012
- no title specified

转载:JSON 入门指南

输出JSON时,要将MIME类型设置成“application/json”。

http://www.ibm.com/developerworks/cn/web/wa-lo-json/

亮点:

好在服务器处理的 JSON 数据最终都应该转化为简单的 JavaScript 对象,因此,递归引用的可能性很小。

最后,通过 Servlet 或 MVC 框架输出 JSON 时,需要设置正确的 MIME 类型(application/json)和字符编码。假定服务器使用 UTF-8 编码,则可以使用以下代码输出编码后的 JSON 文本:

response.setContentType("application/json;charset=UTF-8");

response.setCharacterEncoding("UTF-8");

PrintWriter pw = response.getWriter();

pw.write(JsonUtil.toJson(obj));

pw.flush();

Your opinions
Your name:Email:Website url:Opinion content:
- no title specified

HxLauncher: Launch Android applications by voice commands

 
Recent comments
2017年4月~2019年4月垃圾短信排行榜Posted at:Thu Sep 26 04:51:48 2024
Qt5.7文档翻译:QWebEngineCookieStore类,QWebEngineCookieStore ClassPosted at:Fri Aug 11 06:50:35 2023盲盒kill -9 18289 Grebe.20230517.211749.552.mp4